package com.yyj.controller;

import com.yyj.entity.Rescue;
import com.yyj.entity.Result;
import com.yyj.service.RescueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/rescue")
public class RecuseController {
    @Autowired
    private RescueService rescueService;

    //添加的方法
    @PostMapping("/addRescue")
    public Result addRescue(@RequestBody Rescue rescue) {
        rescueService.addRescue(rescue);
        return Result.success();
    }

    /*请求路径的参数要与@PathVariable的参数一致*/
    @GetMapping("/getRescue/{sendTime}")
    public Result getRescue(@PathVariable String sendTime) {
        List<Rescue> list = rescueService.getRescue(sendTime);
        return Result.success(list);
    }
}
